home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_35 / gus.h < prev    next >
C/C++ Source or Header  |  1995-01-01  |  8KB  |  252 lines

  1. /*
  2.  
  3.   GUS.H
  4.  
  5.   Michael Chen
  6.   mchen@cs.psu.edu
  7.   4/18/1993
  8.   
  9.   See the included .TXT file for terms and other information.
  10.  
  11. */
  12.  
  13. #ifndef __GUS_H
  14. #define __GUS_H
  15.  
  16. /* A few typedefs for convenience. */
  17.  
  18. typedef unsigned char byte;
  19. typedef unsigned int word;
  20. typedef unsigned long longword;
  21.  
  22. /* Define minimum and maximum number of voices. */
  23.  
  24. #define MINVOICES             14
  25. #define MAXVOICES             32
  26.  
  27. /* Command (GUSCommand) defines */
  28.  
  29. #define G_SetVoiceMode        0x0
  30. #define G_SetVoiceFreq        0x1
  31. #define G_SetLoopStartLo      0x2
  32. #define G_SetLoopStartHi      0x3
  33. #define G_SetLoopEndLo        0x4
  34. #define G_SetLoopEndHi        0x5
  35. #define G_SetVolumeRampRate   0x6
  36. #define G_SetVolumeRampStart  0x7
  37. #define G_SetVolumeRampEnd    0x8
  38. #define G_SetVolume           0x9
  39. #define G_SetPositionLo       0xA
  40. #define G_SetPositionHi       0xB
  41. #define G_SetVoiceBalance     0xC
  42. #define G_SetVolumeControl    0xD
  43. #define G_SetMaxVoice         0xE
  44. #define G_DMAControl          0x41
  45. #define G_SetDRAMLo           0x43
  46. #define G_SetDRAMHi           0x44
  47. #define G_TimerControl        0x45
  48. #define G_TimerSpeed          0x46
  49. #define G_SampleControl       0x49
  50. #define G_Initialize          0x4C
  51. #define G_ReadVoiceMode       0x80
  52. #define G_ReadVoiceFreq       0x81
  53. #define G_ReadLoopStartLo     0x82
  54. #define G_ReadLoopStartHi     0x83
  55. #define G_ReadLoopEndLo       0x84
  56. #define G_ReadLoopEndHi       0x85
  57. #define G_ReadVolumeRampRate  0x86
  58. #define G_ReadVolumeRampStart 0x87
  59. #define G_ReadVolumeRampEnd   0x88
  60. #define G_ReadVolume          0x89
  61. #define G_ReadPositionLo      0x8A
  62. #define G_ReadPositionHi      0x8B
  63. #define G_ReadVoiceBalance    0x8C
  64. #define G_ReadVolumeControl   0x8D
  65. #define G_ReadMaxVoice        0x8E
  66. #define G_IRQStatus           0x8F
  67.  
  68. /* Voice mask for use with G_Set/ReadMaxVoice. */
  69.  
  70. #define G_VoiceMask           0xC0
  71.  
  72. /* Mixer control (GUSMixer) defines */
  73.  
  74. #define M_LineInOn            0x0
  75. #define M_LineInOff           0x1
  76. #define M_OutputOn            0x0
  77. #define M_OutputOff           0x2
  78. #define M_MicInOn             0x4
  79. #define M_MicInOff            0x0
  80. #define M_IRQControl          0x40
  81. #define M_DMAControl          0x0
  82.  
  83. /* Voice mode (G_Set/ReadVoiceMode) defines */
  84.  
  85. #define V_VoiceStopped        0x1
  86. #define V_VoiceStarted        0x0
  87. #define V_StopVoice           0x2
  88. #define V_StartVoice          0x0
  89. #define V_16Bit               0x4
  90. #define V_8Bit                0x0
  91. #define V_Loop                0x8
  92. #define V_NoLoop              0x0
  93. #define V_Bidirectional       0x10
  94. #define V_Unidirectional      0x0
  95. #define V_IRQLoop             0x20
  96. #define V_NoIRQLoop           0x0
  97. #define V_Forward             0x0
  98. #define V_Backward            0x40
  99.  
  100. /* Volume control (G_Set/ReadVolumeControl) defines */
  101.  
  102. #define V_RampStopped         0x1
  103. #define V_RampStarted         0x0
  104. #define V_StartRamp           0x0
  105. #define V_StopRamp            0x2
  106. /* same V_Loop/NoLoop defines */
  107. /* same V_Uni/Bidirectional   */
  108. #define V_IRQRamp             0x20
  109. #define V_NoIRQRamp           0x0
  110. #define V_Increasing          0x0
  111. #define V_Decreasing          0x40
  112.  
  113. /* Ramp scale defines */
  114.  
  115. #define R_Every1              0x0
  116. #define R_Every8              0x1
  117. #define R_Every64             0x2
  118. #define R_Every512            0x3
  119.  
  120. /* Voice balance (pan) defines */
  121.  
  122. #define P_Center              0x7
  123. #define P_Left                0x0
  124. #define P_Right               0xF
  125.  
  126. /* Addresses of ports. */
  127.  
  128. extern int GUSBase;
  129. extern int GUSMixer;              /* base         */
  130. extern int GUSStatus;             /* base + 6     */
  131. extern int GUSTimerControl;       /* base + 8     */
  132. extern int GUSTimerData;          /* base + 9     */
  133. extern int GUSIRQDMAControl;      /* base + 0xB   */
  134. extern int GUSMIDIControl;        /* base + 0x100 */
  135. extern int GUSMIDIData;           /* base + 0x101 */
  136. extern int GUSVoice;              /* base + 0x102 */
  137. extern int GUSCommand;            /* base + 0x103 */
  138. extern int GUSDataLo;             /* base + 0x104 */
  139. extern int GUSDataHi;             /* base + 0x105 */
  140. extern int GUSDRAMIO;             /* base + 0x107 */
  141.  
  142. /* Internal variables, but can be seen externally. */
  143.  
  144. extern int GUSCurrentVoice;
  145. extern int GUSVoices;
  146.  
  147. /* Declare frequency divisor table. */
  148.  
  149. extern byte GUSFreqDivisorTable[MAXVOICES+1];
  150.  
  151. /* Prototypes for extern routines. */
  152.  
  153. #ifdef __cplusplus
  154. extern "C" {
  155. #endif
  156.  
  157. extern void GUSDelay();
  158. extern void GUSReset();
  159. extern unsigned char GUSPeek(longword);
  160. extern void GUSPoke(longword, byte);
  161. extern unsigned char GUSPokePeek(longword, byte);
  162. extern unsigned char GUS_Peek(byte, word);
  163. extern void GUS_Poke(byte, word, byte);
  164. extern unsigned char GUS_PokePeek(byte, word, byte);
  165. extern int ProbeGUS();
  166. extern int DetectGUS();
  167.  
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171.  
  172.  
  173. #define GUS_PeekSame()           (inportb(GUSDRAMIO))
  174. #define GUS_PokeSame(x)          (outportb(GUSDRAMIO,x))
  175.  
  176. #ifdef __cplusplus
  177. extern "C" {
  178. #endif
  179.  
  180. extern void GUS_SelectVoice(byte);
  181. extern void GUSSelectVoice(byte);
  182. extern void GUSStopVoice(byte);
  183. extern void GUSStartVoice(byte);
  184. extern void GUSSetVoiceMode(byte voice, byte mode);
  185. extern void GUSSetLoopStart(byte voice, longword addr);
  186. extern void GUSSetLoopEnd(byte voice, longword addr);
  187. extern void GUSSetPosition(byte voice, longword addr);
  188. extern void GUSSetVoiceFreq(byte voice, word freq);
  189. extern void GUSSetVoices(byte voices);
  190. extern longword GUSReadLoopStart(byte voice);
  191. extern longword GUSReadLoopEnd(byte voice);
  192. extern longword GUSReadPosition(byte voice);
  193. extern byte GUSReadVoiceMode(byte voice);
  194. extern word GUSReadVoiceFreq(byte voice);
  195. extern word GUSReadVolume(byte voice);
  196. extern void GUSSetVolume(byte voice, word vol);
  197. extern void GUSSetDRAM(longword addr, void* buf, longword len);
  198. extern void GUSReadDRAM(longword addr, void* buf, longword len);
  199. extern void GUSFillDRAM(longword addr, byte b, longword len);
  200.  
  201. #ifdef __cplusplus
  202. }
  203. #endif
  204.  
  205.  
  206. #define GUS_SetMixer(b)          (outportb(GUSMixer,b))
  207. #define GUS_ReadMixer()          (inportb(GUSMixer))
  208. #define GUS_SetStatus(b)         (outportb(GUSStatus,b))
  209. #define GUS_ReadStatus()         (inportb(GUSStatus))
  210. #define GUS_SetTimerControl(b)   (outportb(GUSTimerControl,b))
  211. #define GUS_ReadTimerControl()   (inportb(GUSTimerControl))
  212. #define GUS_SetTimerData(b)      (outportb(GUSTimerData,b))
  213. #define GUS_ReadTimerData()      (inportb(GUSTimerData))
  214. #define GUS_SetIRQDMAControl(b)  (outport(GUSIRQDMAControl,b))
  215. #define GUS_ReadIRQDMAControl()  (inportb(GUSIRQDMAControl))
  216. #define GUS_SetMIDIControl(b)    (outportb(GUSMIDIControl,b))
  217. #define GUS_ReadMIDIControl()    (inportb(GUSMIDIControl))
  218. #define GUS_SetMIDIData(b)       (outportb(GUSMIDIData,b))
  219. #define GUS_ReadMIDIData()       (inportb(GUSMIDIData))
  220. #define GUS_SetVoice(b)          (outportb(GUSVoice,b))
  221. #define GUS_ReadVoice()          (inportb(GUSVoice))
  222. #define GUS_SetCommand(b)        (outportb(GUSCommand,b))
  223. #define GUS_ReadCommand()        (inportb(GUSCommand))
  224. #define GUS_SetDRAMIO(b)         (outportb(GUSDRAMIO,b))
  225. #define GUS_ReadDRAMIO()         (inportb(GUSDRAMIO))
  226.  
  227. #ifdef __cplusplus
  228. extern "C" {
  229. #endif
  230.  
  231. extern void GUSSetVolumeRampRate(byte voice, byte incr, byte scale);
  232. extern byte GUSReadVolumeRampRate(byte voice);
  233. extern void GUSSetVolumeRampStart(byte voice, word vol);
  234. extern void GUSSetVolumeRampEnd(byte voice, word vol);
  235. extern word GUSReadVolumeRampStart(byte voice);
  236. extern word GUSReadVolumeRampEnd(byte voice);
  237. extern void GUSSetVolumeControl(byte voice, byte mode);
  238. extern byte GUSReadVolumeControl(byte voice);
  239. extern void GUSSetMixer(byte mode);
  240. extern byte GUSReadMixer();
  241. extern void GUSShutUp();
  242. extern void GUSStartRamp(byte voice);
  243. extern void GUSStopRamp(byte voice);
  244. extern void GUSSetVoiceBalance(byte voice, byte pan);
  245. extern byte GUSReadVoiceBalance(byte voice);
  246.  
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250.  
  251. #endif
  252.